<template>
	<view class="search">
		<view class="uni-form-item uni-column">
			<uni-icons type="search" size="18" class="search-icon"></uni-icons>
			<input class="uni-input search-input" confirm-type="search" placeholder="搜索商品" @click="goToSearch()" :value="keyword" disabled="true"/>
		</view>
		<view class="orders" @click="navigateTo('../../pages/my/orders/index')">
			<view class="order-icon">
				<text class="iconfont">&#xe602;</text>
			</view>
			<view class="order-text">
				订单
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'Search',
		props: {
			title: {
				type: String,
				default: 'Search Text'
			},
			type: {
				type: String,
				default: 'Search',
			},
			keyword: {
				type: String,
				default: '',
			},
			api: {
				type: String,
				default: '',
			},
			config: {
				type: Object,
				default: {},
			},
		},
		data() {
			return {
				
			}
		},
		created() {
			//console.log(app.globalData.config)
		},
		methods: {
			goToSearch: function(){
				console.log('goto search page')
				let url = '../../pages/search/index'
				uni.navigateTo({
					url: url
				});
			},
			navigateTo: function(page){
				let that = this
				let url = page
				//console.log(url)
				let userInfo = uni.getStorageSync('userInfo') || {};
				if (userInfo) {
					uni.navigateTo({
						url: url
					});
				}else{
					this.login()
				}
			},
		}
	}
</script>

<style lang="scss">
	.search {
		position: relative;
		display: flex;
		padding: 16rpx 20rpx;
		.uni-form-item {
			position: relative;
			flex: 1;
			.search-input {
				background-color: #f5f6f7;
				border-radius: 30rpx;
				padding: 14rpx 12rpx 14rpx 60rpx;
				font-size: 28rpx;
			}
			.search-icon {
				position: absolute;
				left: 12rpx;
				top: 14rpx;
				color: #000;
			}
		}
		.orders {
			width: 60rpx;
			padding: 0 0 0 10rpx;
			text-align: center;
			color: #777;
			.order-icon {
				height: 38rpx;
				line-height: 38rpx;
			}
			.order-text {
				font-size: 20rpx;
			}
		}
		
	}
</style>
